﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Miris.HumanMilkAnalyser.Repository.EntityFramework;
using Miris.HumanMilkAnalyser.Repository.Interface;
using Miris.HumanMilkAnalyser.Service.Interface;

namespace Miris.HumanMilkAnalyser.Service
{
    /// <summary>
    /// A factory class that manage every single service.
    /// </summary>
    public class ServiceFactory : IServiceFactory
    {
        protected IRepositoryFactory RepositoryFactory;

        /// <summary>
        /// The basic version of Dependency Injection.
        /// </summary>
        /// <param name="repositoryFactory">An instance implements IRepositoryFactory.</param>
        public ServiceFactory(IRepositoryFactory repositoryFactory)
        {
            RepositoryFactory = repositoryFactory;
        }

        public ServiceFactory() : this(new RepositoryFactory()) { }

        /// <summary>
        ///  Create an instance of class that implements IAnalysisResultDiagnosticMessageService to do any related business logic.
        /// </summary>
        /// <returns>The instance of class that implements IAnalysisResultDiagnosticMessageService.</returns>
        public IAnalysisResultDiagnosticMessageService CreateAnalysisResultDiagnosticMessageService()
        {
            return new AnalysisResultDiagnosticMessageService(RepositoryFactory);
        }

        /// <summary>
        ///  Create an instance of class that implements IAnalysisItemService to do any related business logic.
        /// </summary>
        /// <returns>The instance of class that implements IAnalysisItemService.</returns>
        public IAnalysisItemService CreateAnalysisItemService()
        {
            return new AnalysisItemService(RepositoryFactory);
        }

        /// <summary>
        ///  Create an instance of class that implements IAnalysisResultService to do any related business logic.
        /// </summary>
        /// <returns>The instance of class that implements IAnalysisResultService.</returns>
        public IAnalysisResultService CreateAnalysisResultService()
        {
            return new AnalysisResultService(RepositoryFactory);
        }

        /// <summary>
        ///  Create an instance of class that implements IDiagnosticMessageReferenceService to do any related business logic.
        /// </summary>
        /// <returns>The instance of class that implements IDiagnosticMessageReferenceService.</returns>
        public IDiagnosticMessageReferenceService CreateDiagnosticMessageReferenceService()
        {
            return new DiagnosticMessageReferenceService(RepositoryFactory);
        }

        /// <summary>
        ///  Create an instance of class that implements IBreastfeedingSignificanceService to do any related business logic.
        /// </summary>
        /// <returns>The instance of class that implements IBreastfeedingSignificanceService.</returns>
        public IBreastfeedingSignificanceService CreateBreastfeedingSignificanceService()
        {
            return new BreastfeedingSignificanceService(RepositoryFactory);
        }

        /// <summary>
        ///  Create an instance of DataSourceManagementService to do any related business logic.
        /// </summary>
        /// <returns>The instance of DataSourceManagementService.</returns>
        public DataSourceManagementService CreateDataSourceManagementService()
        {
            return new DataSourceManagementService(RepositoryFactory);
        }

        /// <summary>
        ///  Create an instance of BasicConfigurationService to do any related business logic.
        /// </summary>
        /// <returns>The instance of BasicConfigurationService.</returns>
        public BasicConfigurationService CreateBasicConfigurationService()
        {
            return new BasicConfigurationService();
        }

        /// <summary>
        ///  Create an instance of class that implements IPatientService to do any related business logic.
        /// </summary>
        /// <returns>The instance of class that implements IPatientService.</returns>
        public IPatientService CreatePatientService()
        {
            return new PatientService(RepositoryFactory);
        }

        /// <summary>
        ///  Create an instance of class that implements IUnassignedSampleNumberService to do any related business logic.
        /// </summary>
        /// <returns>The instance of class that implements IUnassignedSampleNumberService.</returns>
        public IUnassignedSampleNumberService CreateUnassignedSampleNumberService()
        {
            return new UnassignedSampleNumberService(RepositoryFactory);
        }

        /// <summary>
        ///  Create an instance of RegistrationCodeConfigurationService to do any related business logic.
        /// </summary>
        /// <returns>The instance of RegistrationCodeConfigurationService.</returns>
        public RegistrationCodeConfigurationService CreateRegistrationCodeConfigurationService()
        {
            return new RegistrationCodeConfigurationService();
        }

        /// <summary>
        ///  Create an instance of GenuineCheckService to do any related business logic.
        /// </summary>
        /// <returns>The instance of GenuineCheckService.</returns>
        public GenuineCheckService CreateGenuineCheckService()
        {
            return new GenuineCheckService();
        }
    }
}
